<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<title></title>
		<link href="../../plugins/mui/mui.min.css" rel="stylesheet"/>
		<link href="../../css/index/index_menu.css" rel="stylesheet"/>
		<link href="../../css/style.css" rel="stylesheet"/>
		<script src="../../js/statistics.js"></script>
	</head>
	<body>
		<div class="foot">
			<ul class="clear">
				<li class="active" value="0">
					<div>
						<img src="../../images/icon/home-green.png">
						<p>首页</p>
					</div>
				</li>
				<li value="1">
					<div>
						<img src="../../images/icon/mail-list.png">
						<p>通讯录</p>
					</div>
				</li>
				<li value="2">
					<div>
						<img src="../../images/icon/discover.png">
						<p>同城</p>
					</div>
				</li>
				<li value="3">
					<div>
						<img src="../../images/icon/user.png">
						<p>我的</p>
					</div>
				</li>
				
			</ul>
		</div>
		<script src="../../plugins/mui/mui.min.js"></script>
		<script src="../../plugins/jquery/jquery-3.1.0.min.js"></script>
		<script src="../../js/fontset.js"></script>
		<script>
			var webviewArray = ['../index/main.html','../address_list/address_list_header.html','../city/city.html','../my/my.html'],
				barArray = [];
			mui.init({
				keyEventBind: {
					backbutton: true,  
					menubutton: true   
				}
			});
			
			mui.plusReady(function(){
				initMainWeb();
				$(".foot").find("li").on('tap',function(){
					var value = $(this).attr('value');
					$(this).addClass("active").siblings().removeClass("active");
					var imgSrc = $(this).find("img").attr("src");
					if(imgSrc.indexOf('-green') == -1){
						var newSrc = imgSrc.substr(0,imgSrc.length-4) + '-green.png';
						$(this).find("img").attr("src",newSrc);
					}
					$(this).siblings().each(function(){
						var broSrc = $(this).find("img").attr("src");
						if(broSrc.indexOf('-green') != -1){
							newBroSrc = broSrc.substr(0,broSrc.length-10) + '.png';
							$(this).find("img").attr("src",newBroSrc);
						}
					})
					for(i=0;i<webviewArray.length;i++){
						if(value == i){
							barArray[i].show();
						}else{
							barArray[i].hide();
						}
						
					}
				});
				//关闭启动页
				setTimeout(function(){
					plus.navigator.closeSplashscreen();
				},500);
			})
			//重写back 
			var first = null;
		    mui.back = function(){
		        //首次按键，提示‘再按一次退出应用’
		        if(!first){
		            first = new Date().getTime();
		            mui.toast('再按一次即退出应用');
		            setTimeout(function(){
		                first = null;
		            },1000);
		        }else{
		            if(new Date().getTime()-first<1000){
		                plus.runtime.quit();
		            }
		        }
		    }
		    //初始化加载首页
		    function initMainWeb(){
		    	var menuWebview = plus.webview.currentWebview();
		    	for(i=0;i<webviewArray.length;i++){
		    		barArray[i] = mui.preload({
						url: webviewArray[i],
						id: webviewArray[i],
						styles:{
							top: '0',
							bottom:'50px',
							left:'0',
							bounce: 'vertical'
						},
						waiting:{
				      		autoShow:true,//自动显示等待框，默认为true
				      		title:'正在加载...',//等待对话框上显示的提示内容
      					},
      					extras:{
      						type:0
      					}
					});
					barArray[i].hide();
					menuWebview.append(barArray[i]);
		    	}
				barArray[0].show();
		    }
		</script>
	</body>
</html>
